namespace CodeFirstExample.Migrations
{
    using System.Data.Entity.Migrations;
    
    public partial class AddedLesson : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "Lessons",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "LessonUsers",
                c => new
                    {
                        Lesson_Id = c.Int(nullable: false),
                        User_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Lesson_Id, t.User_Id })
                .ForeignKey("Lessons", t => t.Lesson_Id, cascadeDelete: true)
                .ForeignKey("Users", t => t.User_Id, cascadeDelete: true)
                .Index(t => t.Lesson_Id)
                .Index(t => t.User_Id);
            
        }
        
        public override void Down()
        {
            DropIndex("LessonUsers", new[] { "User_Id" });
            DropIndex("LessonUsers", new[] { "Lesson_Id" });
            DropForeignKey("LessonUsers", "User_Id", "Users");
            DropForeignKey("LessonUsers", "Lesson_Id", "Lessons");
            DropTable("LessonUsers");
            DropTable("Lessons");
        }
    }
}
